package edu.friday.controller;

import edu.friday.common.base.BaseController;
import edu.friday.common.constant.UserConstants;
import edu.friday.common.result.RestResult;
import edu.friday.common.security.LoginUser;
import edu.friday.common.security.service.MyTokenService;
import edu.friday.model.SysMenu;
import edu.friday.model.User;
import edu.friday.model.vo.SysMenuVO;
import edu.friday.service.Userservice;
import edu.friday.utils.BeanUtils;
import edu.friday.utils.http.ServletUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/kaoshi/user")
public class UserController extends BaseController {
    @Autowired
    private Userservice userservice;

    @Autowired
    private MyTokenService myTokenService;

    @GetMapping("/list/{userid}")
    public RestResult list(User User) {

        Long userId=getUserId();

        List<User> User1 =userservice.selectUserList(User,userId);
        return RestResult.success(User1);
    }

    private Long getUserId() {
        LoginUser loginUser = myTokenService.getLoginUser(ServletUtils.getRequest());
        return loginUser.getUser().getId();
    }




}
